package com.whcoding.more.database.controller;

import cn.hutool.core.util.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/dept/")
public class OrmDeptController {


    private static final Logger log = LoggerFactory.getLogger(OrmDeptController.class);

//    @Autowired
//    private OrmDeptService ormDeptService;

    @GetMapping("/hello")
    public String sayHello(@RequestParam(required = false, name = "name") String name) {
        if (StrUtil.isBlank(name)) {
            name = "whcoding";
        }
        return StrUtil.format("Hello World, {}!", name);
    }


    /**
     * 请求地址 ：
     * http://172.16.57.141:9550/dept/queryDeptById?id=1
     * <p>
     * 根据ID 查询数据
     * defaultValue 设置参数默认值
     *
     * @param id
     * @return
     */
    @GetMapping("queryDeptById")
    public ResponseEntity queryDeptById(@RequestParam(value = "id", defaultValue = "0") Long id) {
        log.info("方法queryDeptById,请求参数" + String.valueOf(id));

//        ormDeptService.queryDeptById(Long.valueOf(2));
        return ResponseEntity.ok().build();
    }
}
